import 'dotenv/config';
import type { VercelRequest, VercelResponse } from '@vercel/node';
import{ UpdateUserCmd } from "../../dto/index";
import { handleExceptionRequireLogin } from '../../util/exception';
import { update } from '../../service/user/UserService';
import { success } from '../../util/result';

/**
 * 更新用户自己信息接口
 */
export default async (_req: VercelRequest, _res: VercelResponse) => {
    return await handleExceptionRequireLogin(_req,_res,async (request,response,username) => {
        await update(request.body as UpdateUserCmd,username)
        return response.json(success());
    })
}